from datetime import datetime

format_datetime_string = '%Y-%m-%d %H:%M:%S'


class TailorMonster:
    @staticmethod
    def format_datetime(format_dict):
        """
        递归遍历一个dict, 将其中的datetime格式化成字符串
        :param format_dict:
        :return:
        """
        if isinstance(format_dict, dict):
            return {k: TailorMonster.format_datetime(v) for k, v in format_dict.items()}
        elif isinstance(format_dict, datetime):
            return format_dict.strftime(format_datetime_string)
        else:
            return format_dict


tailor_monster = TailorMonster()
